<?php
use yii\helpers\StringHelper;
use yii\widgets\ListView;
use frontend\assets\SwiperAsset;
use frontend\helpers\SwiperHelper;
/* @var $this yii\web\View */
$this->title = StringHelper::truncate(strip_tags($model->content), 50) . ' - Новости';

\Yii::$app->view->registerMetaTag([
    'name' => 'description',
    'content' => StringHelper::truncate(strip_tags($model->content), 120),
]);

?>

<div class="container">
    <div class="common-page-header">
        <h1>Новости</h1>
        <div class="common-page-header__breadcrumbs">
            <span><a href="/">Главная</a></span>
            <span>/</span>
            <span><a href="/news/index">Новости</a></span>
            <span>/</span>
            <span><?= StringHelper::truncate(strip_tags($model->content), 20) ?></span>
        </div>
    </div>
</div>

<div class="news">
    <div class="container-fluid news__image-container">
        <?= SwiperHelper::generateWithNavigation(frontend\models\News::BUCKET_NAME, $model->prev_img, $model->gallery_img) ?>
    </div>
    <div class="container">
        <div class="row">
            <div class="col-sm-8">
                <p class="news__date"><?= \Yii::$app->formatter->asDatetime($model->date_public, "d.MM.YYYY") ?></p>
                <p class="news__content"><?= $model->content ?></p>
            </div>
        </div>
    </div>
</div>

<?php
    echo ListView::widget([
        'dataProvider' => $newsDataProvider,
        'options' => ['class' => 'container with-gap-and-delimiter'],
        'itemOptions' => [
            'tag' => false,
        ],
        'itemView' => 'newsItem',
        'layout' => '
            <h3 class="mini-header">Смотрите также</h3>
            <div class="news-list-container">{items}</div> 
            <div class="pagination-container">{pager}</div>
        ',
    ]);
?>

<script>
var swiperOptions = {
        loop: true,
        autoplay: {
            delay: 2500,
            disableOnInteraction: false,
        },
        navigation: {
          nextEl: ".slider-button-next",
          prevEl: ".slider-button-prev",
        },
};
</script>
